<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>债权管理</title>
		<link href="plugin/date/date.css" rel="stylesheet">
		<link href="bootstrap/css/bootstrap3.min.css" rel="stylesheet">
		<!-- <link rel="stylesheet" href="https://bootswatch.com/3/cosmo/bootstrap.min.css"> -->
		<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
		<link rel="stylesheet" href="css/nav.css" />
		<style>
			.form-group-update {
				margin-right: 2%;
			}
			.InTheReview,.waitingFor,.beingPerformed,.notThrough,.pendingApproval{
				display: none;
			}
			.cardPic1,.cardPic2,.cardPic3,.licencePic1,.licencePic2{
				display: none;
			}
			.imgsBox  {display: inline-block; margin-right: 5px; margin-top: 5px;}
			.imgsBox img{ width: 100px;}
			/*.tableCon tr th{background-color: #f9f9f9;}*/
		</style>
	</head>

	<body>
		<!--导航-->
	    <nav class="navbar navbar-inverse">
	      <div class="container-fluid">
	        <div class="navbar-header">
	          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
	            <span class="sr-only">Toggle navigation</span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	          </button>
		          	<a class="navbar-brand" href=""><img src="images/admin_logo.png" alt=""></a>
	        </div>

	        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
	          <ul class="nav navbar-nav" id="nav">

	          </ul>
	          <ul class="nav navbar-nav navbar-right">
	            <li class="dropdown">
	              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">欢迎您：<span id="uname"></span><span class="caret"></span></a>
	              <ul class="dropdown-menu" role="menu">
	                <li><a href="change_pass.html">修改密码</a></li>
	                <li><a id="loginOut" href="#">退出登陆</a></li>
	              </ul>
	            </li>
	          </ul>
	        </div>
	      </div>
	    </nav>
		<div class="container-fluid">
			<div class="row bcert-box">
				<ol class="breadcrumb">
				  <li><a href="javascript:;">主页</a></li>
				  <li>债权管理</li>
				  <li class="active">债权管理</li>
				</ol>
		<form class="form-inline searchForm">
			<div class="form-group">
            	<span class="theme-title">债权状态:</span>
	            <select class="form-control drop-down" name='operationType' id="state">
	              <option value="1">待审核</option>
				  <option value="2">审核不通过</option>
				  <option value="3">审核中</option>
				  <option value="4">待执行</option>
				  <option value="5">执行中</option>
				   <option value="6">已完结</option>
				   <option value="7">停止执行</option>
				   <option value="">全部</option>
	            </select>
          </div>
			<div class="form-group">
				<!-- <label for="exampleInputName2">债权编号</label> -->
				<input type="text" class="form-control" id="zid" placeholder="债权编号	">
			</div>
			<div class="form-group">
				<!-- <label for="exampleInputEmail2">债权人账号</label> -->
				<input type="text" class="form-control" id="contact" placeholder="债权人账号">
			</div>
			<div class="form-group">
				<!-- <label for="exampleInputEmail2">代理人账号</label> -->
				<input type="text" class="form-control" id="salesTel" placeholder="代理人账号">
			</div>
			<!-- <button type="button" class="btn btn-primary btn-success" id="Reset"></span>重置</button> -->
			<button type="button" class="btn btn-primary btn-default" id="QueryBtn">查询</button>
		</form>
		<div class="table">
			<table class="table table-bordered table-striped" id="tableData">
				<!-- <tr>
					<th>债权编号</th>
					<th>业务员账号</th>
					<th>债权人账号</th>
					<th>债权金额</th>
					<th>提交时间</th>
					<th>债权状态</th>
					<th>操作</th>
				</tr>
				<tr>
					<td>295</td>
					<td>13716425086</td>
					<td>13716425086</td>
					<td>100000.00</td>
					<td>2017-11-12 13:30:42</td>
					<td>待审核</td>
					<td><button type="button" class="btn btn-sm btn-primary btn-lg" data-toggle="modal" data-target="#gridSystemModal">查看</button></td>
				</tr>
				<tr>
					<td>295</td>
					<td>13716425086</td>
					<td>13716425086</td>
					<td>100000.00</td>
					<td>2017-11-12 13:30:42</td>
					<td>待审核</td>
					<td><button type="button" class="btn btn-sm btn-primary btn-lg" data-toggle="modal" data-target="#gridSystemModal">查看</button></td>
				</tr>
				<tr>
					<td>295</td>
					<td>13716425086</td>
					<td>13716425086</td>
					<td>100000.00</td>
					<td>2017-11-12 13:30:42</td>
					<td>待审核</td>
					<td><button type="button" class="btn btn-sm btn-primary btn-lg" data-toggle="modal" data-target="#gridSystemModal">查看</button></td>
				</tr>
				<tr>
					<td>295</td>
					<td>13716425086</td>
					<td>13716425086</td>
					<td>100000.00</td>
					<td>2017-11-12 13:30:42</td>
					<td>待审核</td>
					<td><button type="button" class="btn btn-sm btn-primary btn-lg" data-toggle="modal" data-target="#gridSystemModal">查看</button></td>
				</tr> -->
			</table>
		</div>
		<!-- 分页 -->
		  <nav aria-label="...">
			<div class="">
			  <span id="pageNum">共&nbsp;<strong></strong>&nbsp;页&nbsp;/&nbsp;</span><span id="totalNum">&nbsp;<strong>0</strong>&nbsp;条数据</span>
			</div>
			<ul id="example"></ul>
		  </nav>
	</div>
	</div>
	<div class="modal fade" tabindex="-1" role="dialog" id="gridSystemModal" aria-labelledby="gridSystemModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
                </button>
                 <h4 class="modal-title" id="gridSystemModalLabel">查看</h4>
            </div>
            <div class="modal-body">
				<!--审核中-->
				<div class="InTheReview">
					<table class="table table-bordered table-condensed tableCon layer-photos-demo">
						<thead>
				        <tr>
				            <th colspan="20" class="align-center" style="color:#fff; text-align: center; background-color:#0c84e4;">
				                债权分配</th>
				        </tr>
				        </thead>
						<tr>
							<th style="background-color: #f9f9f9;">服务费百分比：</th>
							<td ><input type="text" style="width:50px;" id="f_proportion" name="" value="">% 生效比例：<strong id="f_proportion_t"></strong> %，服务费：<strong id="f_proportion_j"></strong></td>
						</tr>
						<tr>
							<th style="background-color: #f9f9f9;">物券比例：</th>
							<td ><input type="text" style="width:50px;"  id="w_proportion" name="" value="">%</td>
						</tr>
						<tr>
							<th style="background-color: #f9f9f9;">金券比例：</th>
							<td ><strong id="x_proportion"></strong>%</td>
						</tr>
					</table>
					<p style="text-align:right;">
						<button type="button" id="proportionBtn" class="btn btn-primary">提交</button>
					</p>
				</div>
				<!--待执行-->
				<div class="waitingFor">
					<table class="table table-bordered table-condensed tableCon layer-photos-demo">
						<thead>
				        <tr>
				            <th colspan="20" class="align-center" style="color:#fff; text-align: center; background-color:#0c84e4;">
				                正在确认执行</th>
				        </tr>
				        </thead>
						<tr>
							<th style="background-color: #f9f9f9;">请求手机号：</th>
							<td id="creditExecuteMobileInfo">
								<!-- <input type="text" id="zphone" class="form-control" style="padding-left:12px;"  placeholder="执行手机号"> -->
							</td>
						</tr>
						<tr>
							<th style="background-color: #f9f9f9;">短信验证码：</th>
							<td >
								<input type="text" id ="vsCode" name="" value="">
								<!-- <a id="phoneCode" class="" href="javascript:;" onclick="verify()">获取验证码</a> -->
								<a href="#" id="phoneCode" class="btn btn-primary btn-sm btn-lg" role="button" onclick="verify()">获取验证码</a>
							</td>
						</tr>
					</table>
					<p style="text-align:right;">
						<button type="button" onclick="beginTthe()" class="btn btn-primary">开始执行</button>
					</p>
				</div>
				<!--执行中-->
				<div class="beingPerformed">
					<table class="table table-bordered table-condensed tableCon layer-photos-demo">
						<thead>
				        <tr>
				            <th colspan="20" class="align-center" style="color:#fff; text-align: center; background-color:#0c84e4;">
				                执行数据</th>
				        </tr>
				        </thead>
						<tr>
							<th style="background-color: #f9f9f9;">返还用户：</th>
							<td id="memberMobile"></td>
						</tr>
						<tr>
							<th style="background-color: #f9f9f9;">剩余余额：</th>
							<td id="surplusMoney"></td>
						</tr>
						<tr>
							<th style="background-color: #f9f9f9;">剩余物券：</th>
							<td id="surplusCoupon"></td>
						</tr>
						<tr>
							<th style="background-color: #f9f9f9;">上次返还金额：	</th>
							<td id="lastReturnMoney"></td>
						</tr>
						<tr>
							<th style="background-color: #f9f9f9;">上次返还购物券：</th>
							<td id="lastReturnCoupon"></td>
						</tr>
					</table>
					<table class="table table-bordered table-condensed tableCon layer-photos-demo">
						<thead>
				        <tr>
				            <th colspan="20" class="align-center" style="color:#fff; text-align: center; background-color:#0c84e4;">
				                执行比例</th>
				        </tr>
				        </thead>
						<tr>
							<th style="background-color: #f9f9f9;">咨询服务费百分比：</th>
							<td ><strong id="executionServiceProportion"></strong>%，服务费：<strong id="serviceCharge"></strong></td>
						</tr>
						<tr>
							<th style="background-color: #f9f9f9;">物券比例：</th>
							<td ><strong id="thingsProportion"></strong>%</td>
						</tr>
						<tr>
							<th style="background-color: #f9f9f9;">金券比例：</th>
							<td ><strong id="amountProportion"></strong>%</td>
						</tr>
					</table>
					<table class="table table-bordered table-condensed tableCon layer-photos-demo">
						<thead>
				        <tr>
				            <th colspan="20" class="align-center" style="color:#fff; text-align: center; background-color:#0c84e4;">
				                执行状态</th>
				        </tr>
				        </thead>
						<tr>
							<th style="background-color: #f9f9f9;">执行状态：</th>
							<td >
								<label><input type="radio" name="optionsRadios" id="status1" value="5">开始执行</label>
								<label><input type="radio" name="optionsRadios" id="status2" value="7">停止执行</label>
							</td>
						</tr>
					</table>
					<p style="text-align:right;">
						<button type="button" class="btn btn-primary" onclick="performStop()" >提交</button>
					</p>
				</div>
				<table class="table table-bordered table-condensed tableCon layer-photos-demo">
					<thead>
			        <tr>
			            <th colspan="20" class="align-center" style="color:#fff; text-align: center; background-color:#0c84e4;">
			                债权编号: <span id="creditorsIdTitle"></span></th>
			        </tr>
			        </thead>
					<tr>
						<th style="background-color: #f9f9f9;">债权编号：</th>
						<td id="creditorsIdInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">债权金额：</th>
						<td id="amountInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">债权类型：</th>
						<td id="creditTypeInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">发布类型：</th>
						<td id="publishTypeInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">产生时间：</th>
						<td id="btimeInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">到期时间：</th>
						<td id="rtimeInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">债权人姓名：</th>
						<td id="creditNameInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">债权人身份证号：</th>
						<td id="creditNumInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">债权人手机号：</th>
						<td id="contactInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">债务人姓名：</th>
						<td id="debtNameInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">债务人身份证号：</th>
						<td id="debtNumInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">债务人手机号：</th>
						<td id="debtPhoneInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">担保人姓名：</th>
						<td id="guaranteeNameInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">担保人证件号：</th>
						<td id="guaranteeCardInfo"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">担保人手机号：</th>
						<td id="guaranteeMobileInfo"></td>
					</tr>
					<tr class="cardPic1">
						<th style="background-color: #f9f9f9;">债权人正面证件照：</th>
						<td id="cardPic1"></td>
					</tr>
					<tr class="cardPic2">
						<th style="background-color: #f9f9f9;">债权人反面证件照：</th>
						<td id="cardPic2"></td>
					</tr>
					<tr class="cardPic3">
						<th style="background-color: #f9f9f9;">债权人手持证件照：</th>
						<td id="cardPic3"></td>
					</tr>
					<tr class="licencePic1">
						<th style="background-color: #f9f9f9;">企业营业执照副本图片：</th>
						<td id="licencePic1"></td>
					</tr>
					<tr class="licencePic2">
						<th style="background-color: #f9f9f9;">企业公章照片：</th>
						<td id="licencePic2"></td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">借条借据：</th>
						<td id="creditborrowpic"  class="imgBoxZ">
							<!-- <img class="img-thumbnail" src="images/1.jpg" alt=""> -->
						</td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">债务合同：</th>
						<td id="creditcontractpic"  class="imgBoxZ">
							<!-- <img class="img-thumbnail" src="images/about.png" alt=""> -->
						</td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">其他：</th>
						<td id="creditotherpic" class="imgBoxZ">
							<!-- <img class="img-thumbnail" src="images/admin_logo.png" alt=""> -->
						</td>
					</tr>
					<tr>
						<th style="background-color: #f9f9f9;">债权状态：</th>
						<td id="stateInfo"></td>
					</tr>
				</table>
				<!--审核不通过-->
				<div class="notThrough">
					<table class="table table-bordered table-condensed tableCon layer-photos-demo">
						<thead>
				        <tr>
				            <th colspan="20" class="align-center" style="color:#fff; text-align: center; background-color:#0c84e4;">
				                审核不通过原因</th>
				        </tr>
				        </thead>
						<tr>
							<th style="background-color: #f9f9f9;">审核不通过原因：</th>
							<td id="reasonInfo"></td>
						</tr>
					</table>
				</div>
            </div>
			<!--待审核-->
            <div class="modal-footer pendingApproval">
				<div class="form-group">
	  	  			<label class="col-sm-3 control-label goods-lb-l">不通过理由</label>
	  	  			<div class="col-sm-9 goods-lb-r">
	  	  				<!-- <input type="text" class="form-control" id="contractNo" placeholder="不通过理由"> -->
						<textarea class="form-control" id="reasonMsg" placeholder="不通过理由" rows="2"></textarea>
	  	  			</div>
  	  		  	</div>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-danger" id="noPass" onclick="claimsAudit(this,2)">不通过</button>
                <button type="button" class="btn btn-primary" id="pass" onclick="claimsAudit(this,3)">通过</button>
            </div>
        </div>
	        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
	</body>
</html>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="plugin/layer/layer.js"></script>
<script type="text/javascript" src="js/cookie.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-paginator.js"></script>
<script type="text/javascript" src="plugin/date/date.js"></script>
<script type="text/javascript" src="plugin/date/date.zh-CN.js"></script>
<script>
var pageUrls = serverURL + '/credit/queryCreditList';
var claimsId = '';
var claimsAmount = '';
$(document).on('input porpertychange change', '#f_proportion', function () {
	var val = $(this).val();
	if (val.length == 1) {
		$("#f_proportion").val(val.replace(/[^0-9]/g, ''));
		val = $("#f_proportion").val();
		$('#f_proportion_j').html((val/100*claimsAmount).toFixed(2))
	} else if (val > 100) {
		$("#f_proportion").val('100');
		val = 100
		$('#f_proportion_j').html((val/100*claimsAmount))
		layer.msg('比例最大100%')
	} else {
		$("#f_proportion").val(val.replace(/\D/g, ''));
		val = $("#f_proportion").val();
		var num = (val/100*claimsAmount).toFixed(2)
		console.log(num)
		$('#f_proportion_j').html((val/100*claimsAmount).toFixed(2))
	}
	$('#f_proportion_t').html(val);

	return;
})
var time;
//发送短信
var phonetest = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/
function verify (){
   var val = $('#creditExecuteMobileInfo').html(); //获取输入手机号码
   // var val = $('#zphone').val()
   var pageUrls = serverURL + '/credit/sendSmsCode';
   if(phonetest.test(val)){
	 time = 60;
	 function timeCountDown(){
	   if(time==0){
		 clearInterval(timer);
		 $('#phoneCode').attr("onclick","verify();")
		 $('#phoneCode').removeClass('disabled').html("发送验证码");
		 return true;
	   }
	   $('#phoneCode').html(time+"S后再次发送");
	   time--;
	   return false;
	 }
	 $('#phoneCode').removeAttr("onclick")
	 $('#phoneCode').addClass('disabled');
	 timeCountDown();
	 var timer = setInterval(timeCountDown,1000);
   }

   // $('#mobile').attr("readonly","readonly");//用disabled，form表单提交不了这个字段
   $.post(serverURL + '/credit/sendSmsCode', {type:'7',id:claimsId,mobile:val},function(data){
	 layer.msg(data.msg)
	 console.log(data)
	 if(data.code == 400){
	   alert(data.msg);
	   return false;
	 }
   });
 }
$(document).on('input porpertychange change', '#w_proportion', function () {
	var val = $(this).val();
	if (val.length == 1) {
		$("#w_proportion").val(val.replace(/[^0-9]/g, ''));
		val = $("#w_proportion").val();
		$('#x_proportion').text(100 - val);
	} else if (val > 100) {
		$("#w_proportion").val('100');
		val = 100
		$('#x_proportion').text(100 - val);
		layer.msg('比例最大100%')
	} else {
		$("#w_proportion").val(val.replace(/\D/g, ''));
		val = $("#w_proportion").val();
		$('#x_proportion').text(100 - val);
	}
	return;
})
	$("document").ready(function() {
		tableList()
		// inputEmpty()
	});

	//列表
	function tableList(){
		data = {
			'salesTel':$('#salesTel').val(),
			'contact':$('#contact').val(),
			'id':$('#zid').val(),
			'state':$('#state').val(),
			'page': page,
			'pageSize': pagesize
		}
		data.page = 1
		ajax(
			pageUrls,
			data,
			pageNumList,
			'post',
			'json'
		)
	}
	//执行数据
	function execution(id){
		data = {
			'id':id,
		}
		var cbk = function(res){
			$('#memberMobile').html(res.data.memberMobile)
			$('#surplusMoney').html(res.data.surplusMoney)
			$('#surplusCoupon').html(res.data.surplusCoupon)
			$('#lastReturnMoney').html(res.data.lastReturnMoney)
			$('#lastReturnCoupon').html(res.data.lastReturnCoupon)
		}
		ajax(
			serverURL + '/credit/queryCreditExceuctDetail',
			data,
			cbk,
			'post',
			'json'
		)
	}

	//数据渲染
	function OpendList(res) {
		var result = '';
		$('#tableData').empty();
		$('#tableData').append(
			'<tr>' +
			'<th>债权id</th>' +
			'<th>业务员账号</th>' +
			'<th>债权人账号</th>' +
			'<th>债权金额</th>' +
			'<th>提交时间</th>' +
			'<th>债权状态</th>' +
			'<th>操作</th>' +
			'</tr>'
		);
		for(var i = 0; i < res.data.list.length; i++) {
			var statenum = res.data.list[i].state;
			var stateNames = ''
			switch (statenum) {
				case 1:
					stateNames = '待审核'
					break;
				case 2:
					stateNames = '审核不通过'
					break;
				case 3:
					stateNames = '审核中'
					break;
				case 4:
					stateNames = '待执行'
					break;
				case 5:
					stateNames = '执行中'
					break;
				case 6:
					stateNames = '已完结'
					break;
				case 7:
					stateNames = '停止执行'
					break;
			}
			result +=
				'<tr>' +
				'<td>' + res.data.list[i].creditSn + '</td>' +
				'<td>' + res.data.list[i].salesTel + '</td>' +
				'<td>' + res.data.list[i].contact + '</td>' +
				'<td>' + res.data.list[i].amount + '</td>' +
				'<td>' + res.data.list[i].ctime + '</td>' +
				'<td>' + stateNames + '</td>' +
				'<td>' +
				'<button type="button" data-id="'+ res.data.list[i].id +'" class="btn btn-sm btn-primary btn-lg view" data-toggle="modal">查看</button>'+
				'</td>' +
				'</tr>'
		}
		$('#tableData').append(result)

	}
	//查询
	$('#QueryBtn').click(function() {
		tableList()
	})

	//债权详情
	$(document).on('click', '.view', function(){
		var id =  $(this).attr('data-id');
		$('#noPass').attr('data-id',id);
		$('#pass').attr('data-id',id);
		var data = {
			'id':id
		}
		var callback = function (res){
			$('#gridSystemModal').modal();
			claimsId = res.data.id;
			var datas = res.data
			var btime = getMyDate(res.data.btime)
			var rtime = getMyDate(res.data.rtime)
			claimsAmount = res.data.amount;
			console.log(claimsId);
			var status = res.data.state
			var statusName = ''
			switch (status) {
			//待审核
			case 1:
				$('.pendingApproval').show()
				statusName = '待审核'
				break;

			//审核不通过
			case 2:
				$('.notThrough').show()
				statusName = '审核不通过'
				$('#reasonInfo').html(res.data.reason)
				break;

			//审核中
			case 3:
				$('.InTheReview').show()
				statusName = '审核中'
				$('#f_proportion').val(res.data.serviceRatio*100)
				$('#f_proportion_t').html(res.data.serviceRatio*100)
				$('#f_proportion_j').html(res.data.service)
				$('#w_proportion').val(res.data.serviceRatio*100)
				$('#x_proportion').html(100-(res.data.serviceRatio*100))
				$('#memberMobile').html(res.data.memberMobile)
				$('#surplusMoney').html(res.data.surplusMoney)
				$('#surplusCoupon').html(res.data.surplusCoupon)
				$('#lastReturnMoney').html(res.data.lastReturnMoney)
				$('#lastReturnCoupon').html(res.data.lastReturnCoupon)
				break;

				//待执行
			case 4:
				statusName = '待执行'
				$('.waitingFor').show()
				$('#creditExecuteMobileInfo').html(res.data.creditExecuteMobile)
				// $('#zphone').val(res.data.creditExecuteMobile)
				break;

				//执行中
			case 5:
				statusName = '执行中'
				$('.beingPerformed').show()
				$('#status1').prop('checked',true)
				$('#status2').prop('checked',false)
				$('#executionServiceProportion').html(res.data.serviceRatio*100)
				$('#serviceCharge').html(res.data.service)
				$('#thingsProportion').html(((1-res.data.cashRatio)*100).toFixed(0))
				$('#amountProportion').html(res.data.cashRatio*100)
				execution(id)
				break;

			//已完结
			case 6:
				statusName = '已完结'
				break;

				//交易完成
			case 7:
				statusName = '停止执行'
				$('.beingPerformed').show()
				$('#status2').prop('checked',true)
				$('#status1').prop('checked',false)
				$('#executionServiceProportion').html(res.data.serviceRatio*100)
				$('#serviceCharge').html(res.data.service)
				$('#thingsProportion').html(((1-res.data.cashRatio)*100).toFixed(0))
				$('#amountProportion').html(res.data.cashRatio*100)
				execution(id)
				break;
			}
			$('#creditorsIdTitle').html(res.data.creditSn)
			$('#creditorsIdInfo').html(res.data.creditSn)
			$('#amountInfo').html(res.data.amount)
			var creditType = res.data.creditType;
			var	creditTypeInt = '';
			if (creditType == 1) {
				creditTypeInt = '个人'
			}else if (creditType == 2) {
				creditTypeInt = '企业'
			}
			var publishType = res.data.publishType;
			var	publishTypeInt = '';
			if (publishType == 1) {
				publishTypeInt = '本人'
			}else if (publishType == 2) {
				publishTypeInt = '代理'
			}
			$('#creditTypeInfo').html(creditTypeInt)
			$('#publishTypeInfo').html(publishTypeInt)
			$('#btimeInfo').html(btime)
			$('#rtimeInfo').html(rtime)
			$('#creditNameInfo').html(res.data.creditName)
			$('#creditNumInfo').html(res.data.creditNum)
			$('#contactInfo').html(res.data.contact)
			$('#debtNameInfo').html(res.data.debtName)
			$('#debtNumInfo').html(res.data.debtNum)
			$('#debtPhoneInfo').html(res.data.debtPhone)
			$('#guaranteeNameInfo').html(res.data.guaranteeName)
			$('#guaranteeCardInfo').html(res.data.guaranteeCard)
			$('#guaranteeMobileInfo').html(res.data.guaranteeMobile)
			$('#stateInfo').html(statusName)
			//借据借条图片
			var imgDatah = res.data.creditborrowpic;
			$('#creditborrowpic').empty();
			var htPic = '';
			if (imgDatah == '' || imgDatah == null) {
				htPic = ''
			}else {
				var imgsh = new Array();
					imgsh=imgDatah.split(",")
				for (var i = 0; i < imgsh.length; i++) {
					htPic += '<div class="imgsBox"><img class="img-thumbnail" src="'+ cncbk_common_tools.imgURL + imgsh[i] +'" alt=""></div>'
				}
				$('#creditborrowpic').append(htPic)
			}

			//债务合同图片
			var imgDataj = res.data.creditcontractpic;
			console.log(res.data.creditcontractpic)
			$('#creditcontractpic').empty();
			var jtPic = '';
			if (imgDataj == '' || imgDataj == null) {
				jtPic = '';
			}else {
				var imgsj = new Array();
					imgsj=imgDataj.split(",")
				for (var i = 0; i < imgsj.length; i++) {
					jtPic += '<div class="imgsBox"><img class="img-thumbnail" src="'+ cncbk_common_tools.imgURL + imgsj[i] +'" alt=""></div>'
				}
				$('#creditcontractpic').append(jtPic)
			}

			//其他图片
			var imgDataq = res.data.creditotherpic;
			$('#creditotherpic').empty();
			var qtPic = '';
			if (imgDataq == '' || imgDataq == null) {
				qtPic = '';
			}else {
				var imgsq = new Array();
					imgsq=imgDataq.split(",")

				for (var i = 0; i < imgsq.length; i++) {
					qtPic += '<div class="imgsBox"><img class="img-thumbnail" src="'+ cncbk_common_tools.imgURL + imgsq[i] +'" alt=""></div>'
				}
				$('#creditotherpic').append(qtPic)
			}
			// layer.ready(function(){ //为了layer.ext.js加载完毕再执行
			// 	layer.photos({
			// 	  photos: '.layer-photos-demo'
			// 	  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
			// 	});
			// });
			// $(".layer-photos-demo img").click(function(){

			//图片加载
			function imglist(field,id){
				var imgDataj = datas.field;
				if(field=='cardpic1'){
					imgDataj = datas.cardpic1;
				}else if (field=='cardpic2') {
					imgDataj = datas.cardpic2;
				}else if (field=='cardpic3') {
					imgDataj = datas.cardpic3;
				}
				console.log(datas)
				console.log(imgDataj)
				id.empty();
				var imgs = '';
				if (imgDataj == '' || imgDataj == null) {
					imgs = '';
				}else {
					imgs = '<div class="imgsBox"><img class="img-thumbnail" src="'+ cncbk_common_tools.imgURL + imgDataj +'" alt=""></div>'
					id.append(imgs)
				}
			}

			//个人代理
			if ( res.data.publishType == 2 && res.data.creditType == 1){
				$('.cardPic1').show()
				$('.cardPic2').show()
				$('.cardPic3').show()
				imglist('cardpic1',$('#cardPic1'))
				imglist('cardpic2',$('#cardPic2'))
				imglist('cardpic3',$('#cardPic3'))
			}
			//企业债权
			if (res.data.creditType == 2) {
				$('.licencePic1').show()
				$('.licencePic2').show()
				imglist(licencePic1,$('#licencePic1'))
				imglist(licencePic2,$('#licencePic2'))
			}		　
		}
		ajax(
			serverURL + '/credit/queryCreditDetail',
			data,
			callback,
			'post',
			'json'
		)
	})

	//债权审核
	function claimsAudit (obj,status){
		if (status == 2) {
			if ($('#reasonMsg').val() == '') {
				layer.msg('请填写不通过理由')
				return false;
			}
		}
		var id = $(obj).attr('data-id')
		var data = {
			'id':id,
			'status':status,
			'reason':$('#reasonMsg').val()
		}
		var callback = function(res){
			layer.msg(res.msg)
			$('#gridSystemModal').modal('hide')
			tableList();
		}
		ajax(
			serverURL + '/credit/updateCreditStatus',
			data,
			callback,
			'post',
			'json'
		)
	}

	//债权开始执行
	function  beginTthe (){
		if ($('#vsCode').val() == '') {
			layer.msg('请填写短信验证码')
			return false;
		}
		var data = {
			'id':claimsId,
			'mobile':$('#creditExecuteMobileInfo').html(),
			// 'mobile':$('#zphone').val(),
			'code':$('#vsCode').val()
		}
		var callback = function(res){
			layer.msg(res.msg)
			$('#gridSystemModal').modal('hide')
			tableList();
		}
		ajax(
			serverURL + '/credit/validateMobileCode',
			data,
			callback,
			'post',
			'json'
		)
	}

	//修改比例
	$('#proportionBtn').click(function(){
		var data = {
			'id':claimsId,
			'serviceRatio':$('#f_proportion').val(),
			'couponRatio':$('#w_proportion').val()
		}
		var callback = function (res){
			layer.msg(res.msg);
			tableList()
			$('#gridSystemModal').modal('hide')
		}
		if ($('#f_proportion').val()=='') {
			layer.msg('请填写服务费比例');
			return false;
		}
		if ($('#w_proportion').val()=='') {
			layer.msg('请填写物券比例');
			return false;
		}
		ajax(
			serverURL + '/credit/updateCreditDistribute',
			data,
			callback,
			'post',
			'json'
		)
	})

	//执行停止执行
	function performStop (){
		var status = $("input[name='optionsRadios']:checked").val()
		var data = {
			'id':claimsId,
			'status':status,
		}
		var callback = function(res){
			layer.msg(res.msg)
			$('#gridSystemModal').modal('hide')
			tableList();
		}
		ajax(
			serverURL + '/credit/updateCreditStatus',
			data,
			callback,
			'post',
			'json'
		)
	}

	//数据清空
	$('#gridSystemModal').on('hidden.bs.modal', function (e) {
		$('.InTheReview').hide()
		$('.waitingFor').hide()
		$('.beingPerformed').hide()
		$('.notThrough').hide()
		$('.pendingApproval').hide()
        $('#reasonMsg').val('')
		$('.cardPic1').hide()
		$('.cardPic2').hide()
		$('.cardPic3').hide()
		$('.licencePic1').hide()
		$('.licencePic2').hide()
		$('#vsCode').val('')
	})
</script>
